package com.qf.java2201.edu.userservice.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @date 2022/6/5
 * @desc
 */
@Configuration
public class MyWebMvcConfigurer  implements WebMvcConfigurer {

    //@Override
    //public void addInterceptors(InterceptorRegistry registry) {
    //    String[] patterns = {"/user/login","/oss/policy"};
    //    registry.addInterceptor(new TokenInterceptor())
    //            .addPathPatterns("/**")
    //            .excludePathPatterns(patterns);  //不拦截这些路径
    //}

    //配置跨域
    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**")
                .allowedOrigins("*")
                .allowedMethods("GET","POST","PUT","DELETE","HEAD","OPTIONS")
                //.allowCredentials(true)
                .allowedHeaders("*");
    }

}
